/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.pacis.shca.domain.entity;

import java.io.Serializable;
import javax.persistence.*;

/**
 *
 * @author solriver
 */
@Entity
@Table(name = "historial_grupo", catalog = "bdshca")
@NamedQueries({
    @NamedQuery(name = "HistorialGrupo.findAll", query = "SELECT h FROM HistorialGrupo h"),
    @NamedQuery(name = "HistorialGrupo.findByMieIdMiembro", query = "SELECT h FROM HistorialGrupo h WHERE h.historialGrupoPK.mieIdMiembro = :mieIdMiembro"),
    @NamedQuery(name = "HistorialGrupo.findByGruIdGrupoFamiliar", query = "SELECT h FROM HistorialGrupo h WHERE h.historialGrupoPK.gruIdGrupoFamiliar = :gruIdGrupoFamiliar"),
    @NamedQuery(name = "HistorialGrupo.findByHgrEstado", query = "SELECT h FROM HistorialGrupo h WHERE h.hgrEstado = :hgrEstado")})
public class GroupRecord implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected GroupRecordPK groupRecordPK;
    @Column(name = "hgr_estado")
    private String state;
    @JoinColumn(name = "vis_id_visita_domiciliaria", referencedColumnName = "id_visita_domiciliaria")
    @ManyToOne(optional = false)
    private HomeVisit homeVisit;
    @JoinColumn(name = "gru_id_grupo_familiar", referencedColumnName = "id_grupo_familiar", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private FamilyGroup familyGroup;
    @JoinColumn(name = "mie_id_miembro", referencedColumnName = "id_miembro", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Member member;

    public GroupRecord() {
    }

    public GroupRecord(GroupRecordPK groupRecordPK) {
        this.groupRecordPK = groupRecordPK;
    }

    public GroupRecord(int mieIdMiembro, int gruIdGrupoFamiliar) {
        this.groupRecordPK = new GroupRecordPK(mieIdMiembro, gruIdGrupoFamiliar);
    }

    public GroupRecordPK getGroupRecordPK() {
        return groupRecordPK;
    }

    public void setGroupRecordPK(GroupRecordPK groupRecordPK) {
        this.groupRecordPK = groupRecordPK;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public HomeVisit getHomeVisit() {
        return homeVisit;
    }

    public void setHomeVisit(HomeVisit homeVisit) {
        this.homeVisit = homeVisit;
    }

    public FamilyGroup getFamilyGroup() {
        return familyGroup;
    }

    public void setFamilyGroup(FamilyGroup familyGroup) {
        this.familyGroup = familyGroup;
    }

    public Member getMember() {
        return member;
    }

    public void setMember(Member member) {
        this.member = member;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (groupRecordPK != null ? groupRecordPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GroupRecord)) {
            return false;
        }
        GroupRecord other = (GroupRecord) object;
        if ((this.groupRecordPK == null && other.groupRecordPK != null) || (this.groupRecordPK != null && !this.groupRecordPK.equals(other.groupRecordPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.pacis.shca.domain.entity.GroupRecord[ groupRecordPK=" + groupRecordPK + " ]";
    }
    
}
